<?php
namespace Kendoctor\HelloBundle\Controller;

use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of SimpleController
 *
 * @author Administrator
 */
class SimpleController extends Controller {
    
    /**
     * 演示控制器的使用 
     * 
     * 继承Symfony\Bundle\FrameworkBundle\Controller\Controller的控制器
     * 控制器的Action可以调用诸多的便利方法
     * 譬如访问request,container,templating,session等等
     * @param Request $request
     * @param type $name
     * @return \Symfony\Component\HttpFoundation\Response 
     */
    public function indexAction(Request $request, $name)
    {
        //request of get method        
        //request of post method
        //$request->request;
        
        //获取Request
        $request2 = $this->getRequest();
        
        //通过Request获取Session
        $session = $request->getSession();
        $session->set("name", $name);
  
        //render输出一个模版返回一个Response
        //return $this->render("KendoctorHelloBundle:Simple:index.html.twig", array('name'=>$name));
        
        //renderView输出一个模版返回输出的文本内容
        $content = $this->renderView("KendoctorHelloBundle:Simple:index.html.twig", array('name'=>$name));
        return new Response($content);
        
    }
    
    public function showAction($name)
    {
        return new Response("name value is ".$name);
    }
}

